<%--
@author Kusal Samarakoon
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="s" uri="/struts-tags" %>

<script type="text/javascript">
    $(document).ready(function () {
        $('.land-table').dataTable({
            "sPaginationType":"full_numbers",
            "bDestroy":true,
            "oLanguage":{
                "sZeroRecords":$('#no-record').val(),
                "sLengthMenu":$('#display').val() + " _MENU_ " + $('#records').val(),
                "sSearch":$('#search').val(),
                //"sInfo":$('#showing').val() + " _START_ " + $('#to').val() + " _END_ " + $('#of').val() + " _TOTAL_ " + $('#entries').val(),
                "sInfo":"" ,
                "sInfoEmpty":$('#no-record').val(),
                "oPaginate":{
                    "sFirst":$('#first').val(),
                    "sLast":$('#last').val(),
                    "sNext":$('#next').val(),
                    "sPrevious":$('#previous').val()
                }
            },
            "fnDrawCallback":function () {
                if ($('.dataTables_paginate span span.paginate_button').size()) {
                    $('.dataTables_paginate')[0].style.display = "block";
                } else {
                    $('.dataTables_paginate')[0].style.display = "none";
                }
            }
        });

        //Onclick View link
        /*    $('#viewLink').click(function () {

         });  */

    });

    /* $(function() {
     $("#tree").treeview({
     collapsed: true,
     animated: "medium",
     control:"#sidetreecontrol",
     persist: "location"
     });
     });  */

    function viewLandDetails(landId) {
        //ajax find land list by parent id
        var url = '${"findClildrenByParentLand.do?landId=' + landId + '"}';
        $.get(url, $(this).serialize(), function(data) {
            $("#landDetails").html(data);
            //if list contain only one element display land details
            //else
            //display in tree
        });
    }

</script>
<div id="land-registration-module-home-title" class="module-home-title">
    <s:a href="searchModule.do"><img src="${pageContext.request.contextPath}/images/search.png"
                                     alt="Land Alienation"><span><s:label
            value="%{getText('search.label')}"/></span></s:a>
    <span class="module-title-breaker"> > </span>
    <s:a href="searchDefineAmLands.do"><img
            src="${pageContext.request.contextPath}/images/searchLand.png"><span><s:label
            value="%{getText('search_defineAM_lands.label')}"/></span></s:a>
    <div id="back-button" align="right">
            <s:form><s:submit value="%{getText('back_btn.label')}" action="searchModule"/></s:form>
        </div>
</div>

<div class="page-title">
    <h2><s:label value="%{getText('search_defineAM_lands.label')}"/></h2>
</div>
<div id="search-lands-form-outer">
    <table>
        <%--<tr>
            <s:form name="searchLandByLandName" id="searchLandByLandName" method="POST">
                <td><s:label value="%{getText('name_of_land.label')}"/></td>
                <td><s:textfield name="searchText" id="searchTextLandName"/></td>
                <td><s:submit action="searchLandByLandName" value="%{getText('search.label')}"/></td>
                <s:hidden name="searchType" value="1"/>
            </s:form>
        </tr>
        <tr>
            <s:form name="searchLandByPlanNo" id="searchLandByPlanNo" method="POST">
                <td><s:label value="%{getText('plan_no.label')}"/></td>
                <td><s:textfield name="searchText" id="searchTextPlanNo"/></td>
                <td><s:submit action="searchLandByPlanNo" value="%{getText('search.label')}"/></td>
                <s:hidden name="searchType" value="2"/>
            </s:form>
        </tr>
        <tr>
            <s:form name="searchLandByLotNo" id="searchLandByLotNo" method="POST">
                <td><s:label value="%{getText('lot_no.label')}"/></td>
                <td><s:textfield name="searchText" id="searchTextLotNo"/></td>
                <td><s:submit action="searchLandByLotNo" value="%{getText('search.label')}"/></td>
                <s:hidden name="searchType" value="3"/>
            </s:form>
        </tr>
        <tr>
            <s:form name="searchLandByHolderName" id="searchLandByHolderName" method="POST">
                <td><s:label value="%{getText('holder_name.label')}"/></td>
                <td><s:textfield name="searchText" id="searchTextHolderName"/></td>
                <td><s:submit action="searchLandByHolderName" value="%{getText('search.label')}"/></td>
                <s:hidden name="searchType" value="4"/>
            </s:form>
        </tr>--%>
    </table>
</div>

<div id="landDetails">

</div>

<table id="land-table" class="width-100 margin-10-auto table land-table">
    <thead>
    <tr>
        <th><s:label value="%{getText('slmsSerialNumber.label')}"/></th>
        <th><s:label value="%{getText('name_of_the_land.label')}"/></th>
        <th><s:label value="%{getText('plan_no.label')}"/></th>
        <th><s:label value="%{getText('lot_no.label')}"/></th>
        <th><s:label value="%{getText('alienation_status.label')}"/></th>
        <th><s:label value="DefineAM"/></th>
        <th><s:label value="%{getText('action.label')}"/></th>
    </tr>
    </thead>
    <tbody>
    <s:iterator status="lands" value="landAssociationList">

        <tr>
            <%--<td width="130px"><s:if test="referenceNumber > 0"><s:property
                    value="referenceNumber"/></s:if><s:else><s:label
                    value="%{getText('undefined.label')}"/></s:else></td>--%>
            <td width="80px"><s:property value="land.id"/></td>
            <td><s:property value="land.nameOfTheLand"/></td>
            <td width="80px"><s:property value="land.planNumber"/></td>
            <td width="80px"><s:property value="land.lotNumber"/></td>
            <td width="180px">
                <%--<s:if test="land.alienationState.ordinal() == 0">
                    <s:if test=" language=='si' ">
                          <s:property value="@lk.icta.common.AppConstants@UN_ALIENATED_SI"/>
                    </s:if>
                    <s:else>
                         <s:property value="land.alienationState"/>
                    </s:else>

                </s:if>
                <s:elseif test="land.alienationState.ordinal() == 1">
                    <s:if test=" language=='si' ">
                         <s:property value="@lk.icta.common.AppConstants@UN_ALIENATED_SI"/>
                    </s:if>
                    <s:else>
                         <s:property value="land.alienationState"/>
                    </s:else>

                </s:elseif>
                <s:else>
                    <s:property value="land.alienationState"/>
                </s:else>--%>
                <s:property value="land.approvalState"/>
            </td>
            <td width="100px"><s:property value="alienationMethod.getEnName()"/></td>
            <td width="80px" class="center-align"><a href="#" title="View" id="viewLink"
                                                     onclick="viewLandDetails('<s:property value="land.id"/>')">
                <img src="${pageContext.request.contextPath}/images/detailed-form.png" style="border:none; width:25px; height:25px;"/> </a></td>
        </tr>

    </s:iterator>
    </tbody>
</table>

<%--
<div id="sidetree">
    <div class="treeheader">&nbsp;</div>
    <div id="sidetreecontrol"><a href="?#">Collapse All</a> | <a href="?#">Expand All</a></div>

    <ul id="treettttt">
        <s:iterator status="lands" value="landList">
            <li><a href="?/index.cfm"><strong><s:property value="referenceNumber"/></strong></a>
                <ul>
                    <li><a href="?/enewsletters/index.cfm">Airdrie eNewsletters </a></li>
                </ul>
            </li>
        </s:iterator>
    </ul>
</div>  --%>




<%-- Localization text for data tables --%>
<s:hidden id="display" value="%{getText('display.label')}"/>
<s:hidden id="records" value="%{getText('records.label')}"/>
<s:hidden id="search" value="%{getText('search.label')}"/>
<s:hidden id="no-record" value="%{getText('no_record.label')}"/>
<s:hidden id="showing" value="%{getText('showing.label')}"/>
<s:hidden id="to" value="%{getText('to.label')}"/>
<s:hidden id="of" value="%{getText('of.label')}"/>
<s:hidden id="entries" value="%{getText('entries.label')}"/>
<s:hidden id="first" value="%{getText('first.label')}"/>
<s:hidden id="last" value="%{getText('last.label')}"/>
<s:hidden id="next" value="%{getText('next.label')}"/>
<s:hidden id="previous" value="%{getText('previous.label')}"/>


